import React from 'react';
import { Result,Button } from 'antd';
import { Component } from "react"
class View404 extends Component {
  timer = null; // class对象的普通属性
  state = {  // 组件状态 但凡状态改变会触发视图更新
    times: this.props.startTime || 5
  };
  componentDidMount() {
    this.timer = setInterval(() => {
      this.setState({
        times: this.state.times - 1
      }, () => {
        if (this.state.times <= 0) {
          this.hanldClick();
        }
      })
    }, 1000)
  }
  componentWillUnmount() {
    clearInterval(this.timer)
  }
  hanldClick = () => {
    window.location.href = "/article";
  }
  render() {
    const { times } = this.state;
    return (
      <div>
        <Result
    status="404"
    title="404"
    subTitle="Sorry, you are not authorized to access this page."
    extra={<Button type="primary">Back Home</Button>}
  />
   <div style={{marginLeft:"600px"}}>您的页面找不到啦，{times}秒自动跳转首页，<button onClick={this.hanldClick}
>点击按钮跳转首页</button></div>

      </div>
    )
  }
}


export default View404;